//
// Created by guo on 24-8-16.
//

#ifndef X32_SHARED_LOCKER_H
#define X32_SHARED_LOCKER_H
#include <mutex>
#include <condition_variable>

class SharedLocker {
public:
    SharedLocker();
    void lock_shared();
    void unlock_shared();
    void lock();
    void unlock();
private:
    std::mutex _mutex;
    std::condition_variable _cv_reader;
    std::condition_variable _cv_writer;
    int _reader_nb{};
    int _writer_nb{};
};

#endif //X32_SHARED_LOCKER_H
